<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        table , td  {
            border:1px solid #fff;
            border-collapse: collapse;
        }
        table tr td {
            width: 100px;
            height: 50px;
            background-color: #ccc;
            text-align: center;
            line-height: 50px;
            font-weight: bold;
        }
        table tr td:nth-of-type(2n) {
            background-color: red;
        }
        table tr td:nth-of-type(2n-1) {
            background-color: green;
        }
        
    </style>
</head>
<body>
    <!-- <table cellpadding="0" cellspacing="0"> -->

    <!--   
            <table>
                <tr>
                    <td>1 * 1 = 1</td>
                </tr>
                <tr>
                    <td>2 * 1 = 2</td>
                    <td>2 * 2 = 2</td>
                </tr>
            </table> 
    -->



    <script>
        // 定义变量 记录html代码字符串
        var str = ""
            str +="<table>"
            str +="    <tr>"
            str +="        <td>1 * 1 = 1</td>"
            str +="    </tr>"
            str +="    <tr>"
            str +="        <td>2 * 1 = 2</td>"
            str +="        <td>2 * 2 = 2</td>"
            str +="    </tr>"
            str +="</table> "
        // 渲染字符串
        document.write(str);
    </script>
</body>
</html>